package com.handpay.zztong.hp.ui;

import android.content.Context;
import android.text.InputFilter;
import android.text.Spanned;
import android.util.AttributeSet;
import android.widget.EditText;
/**
 * 控制金额最大值
 * 
 * @author cqli
 * 
 */
public class UserNameEdit extends EditText implements InputFilter
{
	
	public UserNameEdit(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		// 控制器
		this.setFilters(new InputFilter[] { this });
	}
	
	@Override
	public CharSequence filter(CharSequence source, int start, int end,
			Spanned dest, int dstart, int dend)
	{
		boolean isTrue = true;
		for (int i = 0; i < source.length(); i++)
		{
			char c = source.charAt(i);
			if (c >= 'a' && c <= 'z')
			{
				// 小写字母
			}
			else if (c >= 'A' && c <= 'Z')
			{
				// 大写字母
			}
			else if (c >= '\u4e00' && c <= '\u9fbf')
			{
				// 汉字
			}
			else
			{
				isTrue = false;
				break;
			}
		}
		if (isTrue)
		{
			return source;
		}
		else
		{
			return "";
		}
		
	}
}
